package com.cneport.das.common.model.base;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;

/**
 * @author GavinZhang
 * @version 1.0
 * @desc： 通用响应体
 * @company xxxxxx 公司
 * @date 2021/8/13 14:27
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private String code;
    private String msg;
    private List content;


    public static Result success(String message) {
        return new Result("0", message, null);
    }

    public static Result success(Object obj) {
        if (obj instanceof String) {
            String message = (String) obj;
            return new Result("0", message, null);
        } else {
            return new Result("0", "", Arrays.asList(obj));
        }
    }

    public static Result success() {
        return new Result("0", null, null);
    }

    public static Result success(String message, List content) {
        return new Result("0", message, content);
    }

    public static Result fail(String code, String message, List content) {
        return new Result(code, message, content);
    }


}
